var base = {

  'isNull' : function(val){
      if(val == null || val.length == 0){
          return true;
      }
      return false;
  }
};

layui.use(['form'], function(){
    var form = layui.form;

    var dict = {
        // 是否加空白行
        initDict : function(ele,typeDesc,flag){
            $.ajax({
                url : ctx + '/rbac/dict/findDictTypeByDesc?typeDesc='+typeDesc,
                async : false,
                success : function(res){
                    var str = '';
                    var blank = '<option value=""></option>';
                    if(flag){
                        str += blank;
                    }
                    $.each(res.data,function(i,val){
                        str += '<option value="'+val.dictKey+'">'+val.dictValue+'</option>'
                    });
                    ele.html(str);
                    form.render();
                }
            });
        }
    }

    window.dict = dict;
});

(function($){
    $.fn.formToObject=function(){
        var serializeObj={};
        var array=this.serializeArray();
        var str=this.serialize();
        $(array).each(function(){
            if(serializeObj[this.name]){
                if($.isArray(serializeObj[this.name])){
                    serializeObj[this.name].push(this.value);
                }else{
                    serializeObj[this.name]=[serializeObj[this.name],this.value];
                }
            }else{
                serializeObj[this.name]=this.value;
            }
        });
        return serializeObj;
    };
})(jQuery);
